package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.FavouredConf;
import com.lrkj.payfee.service.IFavouredConfService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 优惠政策设置Controller
 *
 * @author yajun_ren
 * @date 2021-08-14
 */
@RestController
@RequestMapping("/payfee/conf")
public class FavouredConfController extends BaseController
{
    @Autowired
    private IFavouredConfService favouredConfService;

    /**
     * 查询优惠政策设置列表
     */
    @ApiOperation(value = "查询优惠政策设置列表", notes = "查询优惠政策设置列表")
    @GetMapping("/list")
    public TableDataInfo list(FavouredConf favouredConf)
    {
        startPage();
        List<FavouredConf> list = favouredConfService.selectFavouredConfList(favouredConf);
        return getDataTable(list);
    }

    /**
     * 导出优惠政策设置列表
     */
	@ApiOperation(value = "导出优惠政策设置列表", notes = "导出优惠政策设置列表")
    @PreAuthorize("@ss.hasPermi('payfee:conf:export')")
    @Log(title = "优惠政策设置", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FavouredConf favouredConf)
    {
        List<FavouredConf> list = favouredConfService.selectFavouredConfList(favouredConf);
        ExcelUtil<FavouredConf> util = new ExcelUtil<FavouredConf>(FavouredConf.class);
        return util.exportExcel(list, "优惠政策设置数据");
    }

    /**
     * 获取优惠政策设置详细信息
     */
	@ApiOperation(value = "获取优惠政策设置详细信息", notes = "获取优惠政策设置详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:conf:query')")
    @GetMapping(value = "/{favouredConfId}")
    public AjaxResult getInfo(@PathVariable("favouredConfId") String favouredConfId)
    {
        return AjaxResult.success(favouredConfService.selectFavouredConfById(favouredConfId));
    }

    /**
     * 新增优惠政策设置
     */
	  @ApiOperation(value = "新增优惠政策设置", notes = "新增优惠政策设置")
    @PreAuthorize("@ss.hasPermi('payfee:conf:add')")
    @Log(title = "优惠政策设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FavouredConf favouredConf)
    {
        return toAjax(favouredConfService.insertFavouredConf(favouredConf));
    }

    /**
     * 修改优惠政策设置
     */
	 @ApiOperation(value = "修改优惠政策设置", notes = "修改优惠政策设置")
    @PreAuthorize("@ss.hasPermi('payfee:conf:edit')")
    @Log(title = "优惠政策设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FavouredConf favouredConf)
    {
        return toAjax(favouredConfService.updateFavouredConf(favouredConf));
    }

    /**
     * 删除优惠政策设置
     */
	 @ApiOperation(value = "删除优惠政策设置", notes = "删除优惠政策设置")
    @PreAuthorize("@ss.hasPermi('payfee:conf:remove')")
    @Log(title = "优惠政策设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{favouredConfIds}")
    public AjaxResult remove(@PathVariable String[] favouredConfIds)
    {
        return toAjax(favouredConfService.deleteFavouredConfByIds(favouredConfIds));
    }
}
